Picdraw Interpreter version 0.1

Program and documentation Written by Jim Leonard (Trixter / Hornet)

Started on Sun Nov 16 13:51:52 CST 1997
Stopped on Fri Nov 21 02:24:05 CST 1997

Much thanks to Mark Pelczarski (pelczars@mcs.com) for complete PicDraw
Info and permission to write the program.

--------------------------------------------------------------------------

Usage:

To run, type "picdraw filename.ext" (where "filename.ext" is the name of
the file you want to interpret).  For example:

	picdraw trtitle.ms1

After hitting ENTER, a menu will be presented so you can change options,
if desired.

--------------------------------------------------------------------------

Purpose:

This program interprets Graphics Magician Picdraw images and draws the
resulting picture onscreen.  If any bad, reserved, or unimplemented
Picdraw opcodes are encountered, the program will emit a short low buzz
for each bad opcode.  The program will then chirp upon completion.

--------------------------------------------------------------------------

Background:

Picdraw was developed by Penguin Software (later known as Polarware) as
part of a drawing/animation package called The Graphics Magician in 1982
by Mark Pelczarski, David Lubar, and Chris Jochumson.  Picdraw's
strength was storing graphics commands in a small and portable format.
As such, it was used for many Polarware games:  Transylvania, The
Crimson Crown, and many other games and educational programs used it.

While this program could be 100% faithful to the original Apple ][
graphics, I wrote it because I specifically wanted to see if I could
improve picture quality on the PC.  So, I attempted the following
enhancements:

  - Use 110 unique colors for the fill colors (instead of the
    original 6-color dither patterns--yuk!  :-)

  - Optionally interpret PicDraw in 640x480 or higher resolutions

I was partially successful.  Read further in this document to discover
why I stopped developing it.

--------------------------------------------------------------------------

Implementation:

A pointer is "walked" along the Picdraw information, following
this rough flowchart:

  Determine opcode
  Determine opcode parameters
  Set local processing variables, if any
  Perform opcode, emulating with local routines
  Advance pointer to next opcode

Sounds easy enough, eh?  ;-)

Recognized opcodes include:

00: end_of_picture              (many pictures are padded with this at the end)
1x: set_text_cursor                      (sets x,y for the next text character)
2x: set_line_color          (sets the color for lines, rectangles, and circles)
30: xor_text_character_at_cursor
4x: set_brush_number
50: color_text_character_at_cursor
60: set_fill_color                                              (from 0 to 109)
7x: reserved                                (reserved for system-specific data)
8x: set_point                              (set x,y for next line/circle/brush)
9x: draw_box
ax: draw_line
b0: draw_circle
cx: plot_brush
d0: wait                                          (wait in 1/16ths of a second)
ex: fill

--------------------------------------------------------------------------

Notes:

This program is optimized for neither size nor speed, just the standard
stuff: readability, portability, and ease of implementation.  Mostly
ease of implementation.  I don't have much time to code, okay?  :-)
Hey, at least I don't use GOTOs or something equally disgusting...

Yes, this is written in Pascal.  Why Pascal?  Because I know it like the
back of my hand, and this is just a quickie project.  If someone wants
to rewrite this in C for Windows, or assembler for speed/size, or Perl,
or whatever, be my guest.  This code should be easy enough to
understand, save for some possibly redundant levels of abstraction.
Just make sure that you email a copy to both myself and Mark Pelczarski
when you do it.

While it's possible that Picdraw pictures exist over 64K, it's highly
unlikely, so that's why I'm loading the entire thing into a 64K
real-mode segment.  Even if one did exist, it would be fairly trivial to
modify this program to advance a pointer on disk instead of in memory.

The only pictures I had to work with were from Transylvania and Crimson
Crown, both PC versions.  I have a sneaking feeling that I'm not
completely interpreting the *file format* correctly, even though the
pictures mostly come out okay.

--------------------------------------------------------------------------

Currently Not Implemented:

  Opcodes:

    F0 Unpack region   \
    F1 Set Max Region   >-- Don't have access to any pictures that use these
    F2 Set Region Size /

  Features:

    Fills.  They spill most of the time.  The filling function *works*,
    of course, but my specific goal was to create a Picdraw interpreter
    that used real colors instead of the original nasty 6-color
    patterns, and it just doesn't work.  The artists of all the sample
    pictures I have did stuff that just doesn't translate to a
    full-color model, like putting the fill point right next to a line
    instead of in the center of the area, or filling a small area left
    by a bit-pattern fill (which doesn't exist in my version).  As a
    result, the fills leak/spread/etc. and mess up the picture.  It is
    this realization that has caused me to cease development on this
    code, as this is a flaw in my design.  Oh well...

    Full high-res VESA support.  I got discouraged by the above filling,
    so I dropped it halfway through.  It draws lines and circles, and
    that's it.  I should've taken it out, but I left it in for the
    curious.  It is entirely possible that a high-res implementation
    will solve my filling problem, but I don't want to deal with it
    right now.  If some kind soul improves this code, I'd love to see it.

--------------------------------------------------------------------------

Contact, Copying, Copyright, and Distribution Information:

Picdraw and all information related to it is the property of Mark
Pelczarski, who posesses the copyright.  Contact him before distributing
or using Picdraw.

This source code was created by Jim Leonard.  Personally, I don't care
what you do with it as long as you don't violate Mark's copyright and
don't take completely credit for the code.  If you improve it, I'd
*love* to have a copy, since I'm all "Picdraw'd out" to work on it any
more.

Jim Leonard:  trixter@hornet.org
Mark Pelczarski: pelczars@mcs.com

Jimbo's Picdraw Interpreter Home Page (after August 1998):
http://oldskool.org/picdraw/

